﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;


namespace ARXLab_DotNet
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
            DragLabel.MouseMove += new MouseEventHandler(DragLabel_MouseMove);
        }

        private void DragLabel_MouseMove(object sender, MouseEventArgs e)
        {
            if (MouseButtons == MouseButtons.Left)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.DoDragDrop(this,this,DragDropEffects.All,new MyDropTarget());
            }
        }
    }

    public class MyDropTarget : Autodesk.AutoCAD.Windows.DropTarget
    {

        public override void OnDrop(DragEventArgs e)
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            try
            {
                using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    ARXLab_DotNet.adskClass.AddAnEnt();          
                }
            }
            catch (Exception ex)
            {
                ed.WriteMessage("Error handling onDrop:" + ex.Message);
            }
        }
    }
}
